#version 430 core

struct VertexData
{
    vec4 position;
    vec4 color;
    vec4 texCoord;
    vec4 normal;
};

layout (std430, binding=0)buffer Mesh{
    VertexData vertexes[];
}mesh;

out vec4 vs_color;
void main()
{
    // 这是一对组合值，控制的是天顶角的范围的cos值，S控制起点R控制向上加多少
    float RandomRange = 0.6;
    float StartingPoint = 1 - RandomRange; // 为了达到1

    gl_Position = vec4(mesh.vertexes[gl_VertexID].position.xy * 2 - 1, 0.0f, 1.0f);
    float ze = acos(StartingPoint + RandomRange * mesh.vertexes[gl_VertexID].color.x);// 天顶角
    float az = mesh.vertexes[gl_VertexID].color.y*2*3.1415926;// 方位角
    float vx = sin(ze)*cos(az);
    float vy = sin(ze)*sin(az);
    float vz = cos(ze);
    vs_color = vec4((vx+1.0)*0.5, (vy+1.0)*0.5, (vz+1.0)*0.5, mesh.vertexes[gl_VertexID].color.z); // 重映射[-1,1]=>[0,1]
}
